package com.qf.controller;


import com.qf.entity.TlCart;
import com.qf.service.CartService;
import com.qf.utils.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/cart")
public class CartController {
    @Autowired
    CartService cartService;

    @GetMapping("/findAllByUid")//根据用户id查购物车所有商品
    public ResultMsg findAllByUid(HttpServletRequest request){
        return cartService.findAllByUid(request);
    }

    @GetMapping ("/addCart")//加入购物车
    public ResultMsg addCart(Integer gid,Integer num,HttpServletRequest request){
        return cartService.addCart(gid,num,request);
    }

    @GetMapping("/deleteOne")//删除购物车中的一个商品
    public ResultMsg deleteOne(Integer gid){
        return cartService.deleteOne(gid);
    }

    @GetMapping("/deleteAll")//清空购物车
    public ResultMsg deleteAll(HttpServletRequest request){
        return cartService.deleteAll(request);
    }
}
